package com.ruoyi.passenger.orderevaluate.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.passenger.orderevaluate.ro.*;
import com.ruoyi.passenger.orderevaluate.service.OrderEvaluateService;
import com.ruoyi.passenger.orderevaluate.vo.OrderEvaluateByPassengerIdVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * 乘客评价管理
 *
 * @author ruoyi
 * @date 2021-12-01
 */
@RestController
@Api(tags = "乘客评价管理")
@RequestMapping("/orderevaluate/")
public class OrderEvaluateController extends BaseController {

    @Autowired
    private OrderEvaluateService orderEvaluateService;

    /**
     *我的投诉列表
     * @param  * @param
     * @return com.ruoyi.common.core.page.TableDataInfo<java.util.List<com.ruoyi.passenger.orderevaluate.vo.OrderEvaluateByPassengerIdVO>>
     * @throws
     * @Author: xly
     */
    @ApiOperation("我的投诉列表")
    @GetMapping("/get-evaluatelist-by-passengerid")
    @ApiResponses({@ApiResponse(code = 200,message = "操作成功",response = OrderEvaluateByPassengerIdVO.class)})
    public TableDataInfo<List<OrderEvaluateByPassengerIdVO>> getEvaluatelistByPassengerid(@Valid OrderEvaluateListParam param) {
        startPage();
        return getDataTable(orderEvaluateService.getEvaluatelistByPassengerid(param));
    }

    /**
     * {TODO}
     *乘客端订单投诉评价
     * @param  * @param param
     * @return com.ruoyi.common.core.domain.AjaxResult<com.ruoyi.passenger.orderevaluate.vo.OrderEvaluateByOrderIdVO>
     * @throws
     * @Author: xly
     */
    @ApiOperation("通过订单id/评价id查询 订单评价详情")
    @GetMapping("/get-evaluatelist-by-orderid")
    public AjaxResult getEvaluatelistByOrderid(@Valid OrderEvaluateByOrderIdParam param) {
        return AjaxResult.success(orderEvaluateService.getEvaluatelistByOrderid(param));
    }

    /**
     * {TODO}
     *新增订单评价
     * @param  * @param param
     * @return com.ruoyi.common.core.domain.AjaxResult
     * @throws
     * @Author: xly
     */
    @GetMapping("/add-orderevaluate")
    @ApiOperation("新增订单评价")
    public AjaxResult addOrderevaluate(@Valid AddOrderEvaluateParam param){
        return toAjax(orderEvaluateService.addOrderevaluate(param,getLoginUser().getUsername(),"xiaochengxu"));
    }

    /**
     * {TODO}
     *查看处理措施
     * @param  * @param param
     * @return com.ruoyi.common.core.domain.AjaxResult
     * @throws
     * @Author: xly
     */
    @ApiOperation("查看处理措施")
    @GetMapping("/get-handle")
    public AjaxResult getHandle(@Valid GetOrderEvaluateHandleParam param) {
        return AjaxResult.success(orderEvaluateService.getHandle(param));
    }

    @ApiOperation("乘客对处理结果是否满意")
    @PostMapping("/edit-orderevaluate-handle")
    public AjaxResult editOrderEvaluate(@Valid @RequestBody EditOrderEvaluateHandleParam param) {
        return toAjax(orderEvaluateService.editOrderEvaluate(param));
    }
}
